<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>工程竣工验收 - 编写竣工验收报告</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <style>
        body {
            height: auto;
        }

        .content {
            padding: 20px;
        }
        .layui-container {
            padding-top: 20px;
            width: auto;;
        }

        /*单元格备注样式*/
        .layui-table td.tdBz {
            text-align: left;
            padding-left: 0;
            border-left: none;
            color: #aaa;
        }

        .padNone .layui-form-select .layui-input {
            padding-right: 0;
        }

        .hide {
            display: none;
        }

        #superviseStartDate{
            width: 40%;
            display: inline-block;
        }

        #superviseEndDate{
            width: 40%;
            display: inline-block;
        }

        .taleft{
            text-align: left;
        }

        .taleft p:first-child{
            font-weight: 700;
        }
        .ltitle{

        }
    </style>
</head>
<body>
<div class="layui-container">

    <!--基本情况-->
    <div class="layui-collapse">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">竣工项目审查表</h2>
            <div class="layui-colla-content layui-show">
                <form id="form2" class="layui-form layui-form-pane" action="" lay-filter="example2">
                <table class="layui-table v-table">
                    <tbody>
                    <tr class="hide">
                        <td width="24%"></td>
                        <td width="13%"></td>
                        <td width="13%"></td>
                        <td width="24%"></td>
                        <td width="13%"></td>
                        <td width="13%"></td>
                    </tr>
                    <tr>
                        <td class="th8">项目名称</td>
                        <td colspan="2">
                            <input name="prjName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">单位工程名称</td>
                        <td colspan="2">
                            <input name="unitPrjName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">建设地点</td>
                        <td colspan="2">
                            <input name="address" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">结构类型</td>
                        <td colspan="2">
                            <input name="jglx" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">层数</td>
                        <td colspan="2">
                            <input name="cs" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">建筑面积</td>
                        <td colspan="2">
                            <input name="totalArea" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">工程规模</td>
                        <td colspan="2">
                            <input name="prjScale" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">开工日期</td>
                        <td colspan="2">
                            <input name="planStartTime" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">竣工验收合格时间</td>
                        <td colspan="2">
                            <input name="qualifiedDate" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">工程施工许可证号</td>
                        <td colspan="2">
                            <input name="gcsgxkzh" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">施工图审查批准号</td>
                        <td colspan="2">
                            <input name="sgtscph" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">建设单位</td>
                        <td colspan="2">
                            <input name="buildCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">勘察单位</td>
                        <td colspan="2">
                            <input name="kcCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">设计单位</td>
                        <td colspan="2">
                            <input name="sjCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">施工图审查单位</td>
                        <td colspan="2">
                            <input name="stCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td class="th8">监理单位</td>
                        <td colspan="2">
                            <input name="jlCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                        <td class="th8">施工单位</td>
                        <td colspan="2">
                            <input name="sgCorpName" class="layui-input formData1" autocomplete="off" readonly>
                        </td>
                    </tr>
                    </tbody>
                </table>
                </form>
            </div>
        </div>
    </div>

    <form id="form" class="layui-form layui-form-pane" action="" lay-filter="example">
        <input type="hidden" name="id" class="formData" value="">
        <input type="hidden" name="cptId" class="formData" value="">
        <!--审查项目及内容-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">审查项目及内容</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>一、完成项目设计情况</p>
                                <p>1.基础、主体、室内外装饰工程</p>
                                <p>2.给排水、燃气、消防工程</p>
                                <p>3.建筑电气安装</p>
                                <p>4.通风与空调工程</p>
                                <p>5.电梯、电扶梯安装工程</p>
                                <p>6.室外工程</p>
                                <p>7.市政道路、桥梁工程</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="8" class="layui-textarea formData" name="reviewItem1"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>二、完成合同约定情况</p>
                                <p>1.总包合同约定</p>
                                <p>2.分包合同约定</p>
                                <p>3.专业承包合同约定</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="4" class="layui-textarea formData" name="reviewItem2"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>三、技术档案和施工管理资料</p>
                                <p>1.建设前期、施工图设计审查等技术档案</p>
                                <p>2.监理技术档案和资料管理</p>
                                <p>3.施工技术档案和管理资料</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="4" class="layui-textarea formData" name="reviewItem3"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>四、实验报告</p>
                                <p>1.主要建筑材料</p>
                                <p>2.构配件</p>
                                <p>3.设备</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="4" class="layui-textarea formData" name="reviewItem4"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>五、质量合格文件</p>
                                <p>1.勘察单位</p>
                                <p>2.设计单位</p>
                                <p>3.施工图审查机构</p>
                                <p>4.施工单位</p>
                                <p>5.监理单位</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="6" class="layui-textarea formData" name="reviewItem5"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 taleft" colspan="1">
                                <p>六、工程质量保修书</p>
                                <p>1.总分包单位</p>
                                <p>2.专业承包单位</p>
                            </td>
                            <td colspan="5">
                                <textarea rows="3" class="layui-textarea formData" name="reviewItem6"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="th8" colspan="1">审查结论</td>
                            <td colspan="5">
                                <input name="reviewConclusion" class="layui-input formData" autocomplete="off">
                            </td>
                        </tr>
                        <tr>
                            <td class="th8" colspan="1">审查日期</td>
                            <td colspan="5">
                                <input id="reviewDate" name="reviewDate" class="layui-input formData" autocomplete="off">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <input type="button" id="sign1" value="签章" class="layui-btn" style="display:none" lay-filter="sign1">
                    <input type="button" id="sign11" value="重新签章" class="layui-btn" style="display:none" lay-filter="sign11">
                    <input type="button" id="download1" value="下载附件" style="display:none" lay-filter="download1" class="layui-btn layui-btn-xs">
                </div>
            </div>
        </div>


        <!--单位工程质量评定表-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">单位工程质量评定表</h2>
                <div class="layui-colla-content layui-show">
                    <script type="text/html" id="toolbarOrg">
                        <div class="layui-btn-container">
                            <input type="button"class="layui-btn" lay-event="add" value="新建">
                        </div>
                    </script>
                    <script type="text/html" id="toolbarOrg2">
                        <div class="layui-btn-container">
                            <!--不能修改-->
                        </div>
                    </script>
                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="delete">删除</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="sign2">签章</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="sign22">重新签章</a>
                    </script>
                    <script type="text/html" id="barDemo2">
                        <!--不能修改-->
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="download2">下载附件</a>
                    </script>
                    <table class="layui-hide" id="dataList" lay-filter="dataList"></table>
                </div>
            </div>
        </div>
    </form>


    <!--竣工验收情况表-->
    <form id="form1" class="layui-form layui-form-pane" action="" lay-filter="example1">
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">竣工验收情况</h2>
                <div class="layui-colla-content layui-show">
                    <p class="ltitle">1、领导验收小组</p>
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8">组长</td>
                            <td colspan="2">
                                <input name="leader" lay-verify="isEmpty" type="text"
                                       class="layui-input formData2" placeholder="组长名称" autocomplete="off">
                            </td>
                            <td class="th8">副组长</td>
                            <td colspan="2">
                                <input name="deputyLeader" lay-verify="isEmpty" type="text"
                                       class="layui-input formData2" placeholder="副组长名称" autocomplete="off">
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 required">成员</td>
                            <td colspan="5">
                                <input name="members" type="text" lay-verify="isEmpty|uname" class="layui-input formData2"
                                       placeholder="成员名称" autocomplete="off">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>

                <!--各专业验收组-->
                <div class="layui-colla-content layui-show" style="min-height: 100px;">
                    <div><p class="ltitle">2、各专业验收组</p></div>
                    <table class="layui-hide" id="dataList2" lay-filter="dataList2"></table>
                </div>

                <!--竣工验收结论-->
                <div class="layui-colla-content layui-show">
                    <p class="ltitle">3、竣工验收结论</p>
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8 required">竣工验收结论</td>
                            <td colspan="5">
                                <textarea rows="5" cols="" class="layui-textarea formData" name="conclusion" id="conclusion" autocomplete="off" readonly></textarea>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>

            </div>
        </div>

    </form>

</div>
<script src="/static/js/main.js"></script>
<script type="text/javascript">
    var $;
    layui.use(['jquery', 'element', 'form', 'laydate', 'configure', 'configureCom', 'selectFun', 'bluebird', 'replaceStr', 'jsDictFile', 'mapExtend'], function () {
        $ = layui.jquery;
        var element = layui.element;
        var form = layui.form;
        var configure = layui.configure;
        var table = layui.table;
        var configureCom = layui.configureCom;
        var laydate = layui.laydate;
        var selectFun = layui.selectFun;
        var sessionFun = layui.sessionFun;//存储session
        var listData = sessionFun.get(configure.COMPLETION_ROW_DATA);
        var token = sessionFun.get(configure.SESSION_TOKEN) ? sessionFun.get(configure.SESSION_TOKEN).token : '';
        var cptStatus = sessionFun.get( 'CPT_STATUS');
//        var id = '';
        var reviewDate = '';
        var status = '';

        var cptAcceptanceId = sessionFun.get('cptAcceptanceId');
        //初始化竣工验收申请状态, 用户判断表单(表格或文件上传)是否可以修改
        if (listData) {
            cptAcceptanceId = listData.id;
            status = listData.status;
        }else if(cptAcceptanceId){
            var res={};
            var data1 = $.extend({cptAcceptanceId:cptAcceptanceId}, {token: token});
            var index = top.layer.load(1, {shade: 0.01});
            $.ajax({
                url: configure.COMPLETION_DETAIL_INFO,
                type: 'get',
                cache: false,
                async:false,
                data: data1,
                dataType: 'json',
                success: function (data) {
                    top.layer.close(index);
                    res = data;
                },
                error: function (data) {
                    top.layer.close(index);
                }
            });
            if(res.data){
                status = res.data.status;
            }else{
                console.log("未找到竣工验收申请记录"+cptAcceptanceId);
            }
        }


        /**
         * 表单初始化
         *
         * */
        var res={};
        var data1 = $.extend({cptId:cptAcceptanceId}, {token: token});
        var index = top.layer.load(1, {shade: 0.01});
        $.ajax({
            url: configure.CPT_ACCEPTANCE_CONDITION_REPORT_VIEW_API,
            type: 'get',
            cache: false,
            async:false,
            data: data1,
            dataType: 'json',
            success: function (data) {
                top.layer.close(index);
                res = data;
            },
            error: function (data) {
                top.layer.close(index);
            }
        });
        //如果查到条件核查记录表单赋值
        if(res.data && res.data.id){
            form.val('example', res.data);
            reviewDate = res.data.reviewDate;
        }else{
            //如果没有查到核查记录 则为新增, 表单赋值仅有申请ID
            var newData = { cptId: cptAcceptanceId};
            form.val('example', newData);
        }


        laydate.render({
            elem: '#reviewDate',
            type: 'date',
            value: (reviewDate)?reviewDate:new Date()
        });


        /**
         * 初始化项目信息
         *
         * */
        $.ajax({
            url: '/api/cpt/acceptance/report/prjInfo?token='+token,
            type: 'get',
            cache: false,
            async:false,
            data: {cptId:cptAcceptanceId},
            dataType: 'json',
            success: function (data) {
                res = data;
                //如果查到项目信息
                if(data.code==0){
                    form.val('example2', res.data);
                }else{
                    console.log('查询项目信息错误:'+res.msg);
                }
            },
            error: function (data) {
                console.log('查询项目信息异常,cptAcceptanceId:'+cptAcceptanceId);
            }
        });


        /**
         * 初始化专业验收小组
         */
        var cols = [[
            {field: 'specialty', title: '专业名称'},
            {field: 'leader', title: '组长' },
            {field: 'members', title: '组员'},
        ]];
        configureCom.tableRenderGet(configure.CPT_ACCEPTANCE_TEAM_LIST_API, {cptId: cptAcceptanceId}, cols, 'dataList2', 10, '', '',false);

        /**
         * 初始化 竣工申请小组情况
         */
        var res={};
        var data1 = $.extend({cptAcceptanceId:cptAcceptanceId}, {token: token});
        var index = top.layer.load(1, {shade: 0.01});
        $.ajax({
            url: configure.COMPLETION_DETAIL_INFO,
            type: 'get',
            cache: false,
            async:false,
            data: data1,
            dataType: 'json',
            success: function (data) {
                top.layer.close(index);
                res = data;
                if(res.data){
                    form.val('example1', res.data);
                }else{
                    console.log("未找到 竣工验收申请记录, cptAcceptanceId:"+cptAcceptanceId);
                }
            },
            error: function (data) {
                top.layer.close(index);
            }
        });

        //验收结论初始化
        var _index = top.layer.load(1, {shade: 0.01});
        $.ajax({
            url: configure.CPT_ACCEPTANCE_CONCLUSION_VIEW_API+"?token="+token,
            type: 'get',
            cache: false,
            async:false,
            data: {cptAcceptanceId:cptAcceptanceId},
            dataType: 'json',
            success: function (data) {
                top.layer.close(_index);
                res = data;
                if(res.data && res.data.id){
                    form.val('example1', res.data);
                }
            },
            error: function (data) {
                top.layer.close(_index);
            }
        });

        //验收结论初始化
        var _index = top.layer.load(1, {shade: 0.01});
        $.ajax({
            url: configure.CPT_ACCEPTANCE_SUPERVISE_REPORT_VIEW_API+"?token="+token,
            type: 'get',
            cache: false,
            async:false,
            data: {cptAcceptanceId:cptAcceptanceId},
            dataType: 'json',
            success: function (data) {
                top.layer.close(_index);
                res = data;
                if(res.data && res.data.id){
                    $("#qualifiedDate").val(res.data.qualifiedDate);
                }
            },
            error: function (data) {
                top.layer.close(_index);
            }
        });


        //监听下载1
        $("#download1").click(function(data){
            window.open("/api/cpt/acceptance/report/jgxmscFile/sign/download?token="+token + "&cptId="+cptAcceptanceId);
        });

        //监听签名1
        $("#sign1").click(function(data){
            //TODO 后台根据模板生成pdf文件
            var res1 = null;
            var data1 = {id:cptAcceptanceId, reSign:0};
            $.ajax({
                url: '/api/cpt/acceptance/report/jgxmscFile/create?token='+token,
                type: 'post',
                cache: false,
                async:false,
                contentType : 'application/json',
                dataType : 'json',
                data :JSON.stringify(data1),
                success: function (data) {
                    res1 = data;
                    layer.closeAll('loading');
                },
                error: function (data) {
                    layer.closeAll('loading');
                    layer.msg(data.msg?data.msg:"操作失败");
                }
            });

            //查询竣工验收详情, 并判断状态, 是否显示保存按钮
            if(res1 && res1.code==0){
                sessionFun.set(configure.SESSION_SIGN_DATA,{id:cptAcceptanceId, fileName:res1.data.fileName, attId:res1.data.attId});
                //打开插件工具, 盖章上传
                top.layer.open({
                    type: 2,
                    title: '上传附件',
                    content: 'pages/completion/sign/jgxmscSign.html',
                    area: configureCom.Psize1,
                    cancel: function (index, layero) {
//                        configureCom.tableReloadById(table12.id);
                    },
                    btn: ['保存签章'],
                    yes: function (index, layero) {
                        var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                        iframeWin.signSave().then(function (res) {
                            if (res.code == 1) {
                                top.layer.msg(res.msg);
                                top.layer.close(index);
                                configureCom.tableReloadById(table12.id);
                            } else {
                                top.layer.alert(res.msg);
                            }
                        });
                    }
                });
            }else if(res1.code){
                layer.msg(res1.msg?res1.msg:"操作失败.");
                return;
            }else{
                layer.msg("操作失败!");
                return;
            }
        });


        //监听重新签名
        $("#sign11").click(function(data){
            //TODO 后台根据模板生成pdf文件
            var res1 = null;
            var data1 = {id:cptAcceptanceId, reSign:1};
            $.ajax({
                url: '/api/cpt/acceptance/report/jgxmscFile/create?token='+token,
                type: 'post',
                cache: false,
                async:false,
                contentType : 'application/json',
                dataType : 'json',
                data :JSON.stringify(data1),
                success: function (data) {
                    res1 = data;
                    layer.closeAll('loading');
                },
                error: function (data) {
                    layer.closeAll('loading');
                    layer.msg(data.msg?data.msg:"操作失败");
                }
            });

            //查询竣工验收详情, 并判断状态, 是否显示保存按钮
            if(res1 && res1.code==0){
                sessionFun.set(configure.SESSION_SIGN_DATA,{id:cptAcceptanceId, fileName:res1.data.fileName, attId:res1.data.attId});
                //打开插件工具, 盖章上传
                top.layer.open({
                    type: 2,
                    title: '上传附件',
                    content: 'pages/completion/sign/jgxmscSign.html',
                    area: configureCom.Psize1,
                    cancel: function (index, layero) {
//                        configureCom.tableReloadById(table12.id);
                    },
                    btn: ['保存签章'],
                    yes: function (index, layero) {
                        var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                        iframeWin.signSave().then(function (res) {
                            if (res.code == 1) {
                                top.layer.msg(res.msg);
                                top.layer.close(index);
                                configureCom.tableReloadById(table12.id);
                            } else {
                                top.layer.alert(res.msg);
                            }
                        });
                    }
                });
            }else if(res1.code){
                layer.msg(res1.msg?res1.msg:"操作失败.");
                return;
            }else{
                layer.msg("操作失败!");
                return;
            }
        });

        //待办进入, 不显示下载按钮, 根据状态显示签字按钮
        if(sessionFun.get('cptAcceptanceId')){
            //6-编写竣工报告中
            if(cptStatus && cptStatus==6){
                $("#sign1").css("display","");
                $("#sign11").css("display","");
            }else{
                $("#download1").css("display","");
            }
        }else{
            //验收记录进入, 显示下载按钮, 不显示签字按钮
            $("#download1").css("display","");
            $("#sign1").css("display","none");
            $("#sign11").css("display","none");
        }

        form.render();


        /**
         * 单位工程质量评定表
         */
        var cols = [[
            {field: 'unitPrjName', title: '单位工程名称'},
            {field: 'appeQuality', title: '观感质量评价' , templet: function (d) {
                if("1"==d.appeQuality){
                    return "好";
                }else if("2"==d.appeQuality){
                    return "一般";
                }else if("3"==d.appeQuality){
                    return "差";
                }else{
                    return "";
                }
            }},
            {field: 'evalDate', title: '日期'},
            {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 320}
        ]];
        var cols2 = [[
            {field: 'unitPrjName', title: '单位工程名称'},
            {field: 'appeQuality', title: '观感质量评价', templet: function (d) {
                if("1"==d.appeQuality){
                    return "好";
                }else if("2"==d.appeQuality){
                    return "一般";
                }else if("3"==d.appeQuality){
                    return "差";
                }else{
                    return "";
                }
            }},
            {field: 'evalDate', title: '日期'},
            {fixed: 'right', title: '操作', toolbar: '#barDemo2', width: 320}
        ]];
        //状态-6 才可以修改
        if(status==6){
            configureCom.tableRenderGet(configure.CPT_ACCEPTANCE_REPORT_QUALITY_LIST_API, {cptId: cptAcceptanceId}, cols, 'dataList', 10, '', 'toolbarOrg',false);
        }else{
            configureCom.tableRenderGet(configure.CPT_ACCEPTANCE_REPORT_QUALITY_LIST_API, {cptId: cptAcceptanceId}, cols2, 'dataList', 10, '', 'toolbarOrg2',false);
        }
        //头工具栏事件
        table.on('toolbar(dataList)', function (obj) {
            switch (obj.event) {
                case 'add':
                    sessionFun.set(configure.SESSION_LIST_DATA, null);
                    editItem('单位工程质量评定表', configure.CPT_ACCEPTANCE_REPORT_QUALITY_EDIT_HTML, configure.CPT_ACCEPTANCE_REPORT_QUALITY_SAVE_API);
                    break;
            }
        });
        //查看详情字典详情
        function editItem(title, htmlUrl, srvUrl) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize2,
                content: configureCom.nocache(htmlUrl),
                btn: ['保存'],
                yes: function (index, layero) {
                    debugger;
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData();
                    //保存验收记录小组关联申请ID
                    data.cptId = cptAcceptanceId;
                    configureCom.postDataAjax(srvUrl, data).then(function (res) {
                        if (res.code == 0) {
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                        } else {
                            top.layer.alert('保存失败！');
                        }
                    });
                },
                end: function () {
                    configureCom.tableReloadById('dataList');
                }
            });
        }
        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delete') {
                //删除各专业验收组
                $.ajax({
                    type: "DELETE",
                    url: configure.CPT_ACCEPTANCE_REPORT_QUALITY_REMOVE_API+'/'+data.id+'?token='+token,
                    data: {
                    },
                    success: function (data) {
                        var code = data.code;
                        var msg = data.msg;
                        if (code == "0" || msg == "success") {

                        } else {
                            layer.msg(data.msg);
                        }
                        layer.closeAll('loading');
                        //页面刷新
                        configureCom.tableReloadById('dataList');
                    }
                });
            }else if (obj.event === 'sign2') {
                //后台根据模板生成pdf文件
                var res1 = null;
                var data1 = {id:data.id, cptId:cptAcceptanceId, reSign:0};
                $.ajax({
                    url: '/api/cpt/acceptance/report/dwgczlpdFile/create?token='+token,
                    type: 'post',
                    cache: false,
                    async:false,
                    contentType : 'application/json',
                    dataType : 'json',
                    data :JSON.stringify(data1),
                    success: function (data) {
                        res1 = data;
                        layer.closeAll('loading');
                    },
                    error: function (data) {
                        layer.closeAll('loading');
                        layer.msg(data.msg?data.msg:"操作失败");
                    }
                });

                //查询竣工验收详情, 并判断状态, 是否显示保存按钮
                if(res1 && res1.code==0){
                    sessionFun.set(configure.SESSION_SIGN_DATA,{id:data.id, fileName:res1.data.fileName, attId:res1.data.attId});
                    //打开插件工具, 盖章上传
                    top.layer.open({
                        type: 2,
                        title: '上传附件',
                        content: 'pages/completion/sign/dwgczlpdSign.html',
                        area: configureCom.Psize1,
                        cancel: function (index, layero) {
//                        configureCom.tableReloadById(table12.id);
                        },
                        btn: ['保存签章'],
                        yes: function (index, layero) {
                            var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.signSave().then(function (res) {
                                if (res.code == 1) {
                                    top.layer.msg(res.msg);
                                    top.layer.close(index);
//                                    configureCom.tableReloadById(table12.id);
                                } else {
                                    top.layer.alert(res.msg);
                                }
                            });
                        }
                    });
                }else if(res1.code){
                    layer.msg(res1.msg?res1.msg:"操作失败.");
                    return;
                }else{
                    layer.msg("操作失败!");
                    return;
                }
            }else if(obj.event === 'sign22') {
                //后台根据模板生成pdf文件
                var res1 = null;
                var data1 = {id:data.id, cptId:cptAcceptanceId, reSign:1};
                $.ajax({
                    url: '/api/cpt/acceptance/report/dwgczlpdFile/create?token='+token,
                    type: 'post',
                    cache: false,
                    async:false,
                    contentType : 'application/json',
                    dataType : 'json',
                    data :JSON.stringify(data1),
                    success: function (data) {
                        res1 = data;
                        layer.closeAll('loading');
                    },
                    error: function (data) {
                        layer.closeAll('loading');
                        layer.msg(data.msg?data.msg:"操作失败");
                    }
                });

                //查询竣工验收详情, 并判断状态, 是否显示保存按钮
                if(res1 && res1.code==0){
                    sessionFun.set(configure.SESSION_SIGN_DATA,{id:data.id, fileName:res1.data.fileName, attId:res1.data.attId});
                    //打开插件工具, 盖章上传
                    top.layer.open({
                        type: 2,
                        title: '上传附件',
                        content: 'pages/completion/sign/dwgczlpdSign.html',
                        area: configureCom.Psize1,
                        cancel: function (index, layero) {
//                        configureCom.tableReloadById(table12.id);
                        },
                        btn: ['保存签章'],
                        yes: function (index, layero) {
                            var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            iframeWin.signSave().then(function (res) {
                                if (res.code == 1) {
                                    top.layer.msg(res.msg);
                                    top.layer.close(index);
//                                    configureCom.tableReloadById(table12.id);
                                } else {
                                    top.layer.alert(res.msg);
                                }
                            });
                        }
                    });
                }else if(res1.code){
                    layer.msg(res1.msg?res1.msg:"操作失败.");
                    return;
                }else{
                    layer.msg("操作失败!");
                    return;
                }
            }else if (obj.event === 'download2') {
                window.open("/api/cpt/acceptance/report/dwgczlpdFile/sign/download?token="+token + "&id="+data.id);
            }
            else if(obj.event === 'edit'){
                sessionFun.set(configure.SESSION_LIST_DATA, data);
                editItem('单位工程质量评定表', configure.CPT_ACCEPTANCE_REPORT_QUALITY_EDIT_HTML, configure.CPT_ACCEPTANCE_REPORT_QUALITY_SAVE_API);
            }
        });

    });

    function getData() {
        return new Promise(function (res, rej) {
            var data = {};
            if (!window.formVerifyFun()) {
                //return false;
            }

            $('.formData').each(function (index, item) {
                var key = $(item).attr('name');
                var type = $(item).attr('type');
                if(type=='radio'){
                    data[key] = $("input[name='"+key+"']:checked").val();
                }else{
                    data[key] = $(item).val();
                }

            });
            res({result: data});
        });
    }
</script>
</body>
</html>
